package reduce.fz.com.reduce.util.http;

import android.text.TextUtils;

import com.android.volley.AuthFailureError;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.apache.http.Header;
import org.apache.http.auth.AUTH;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.auth.DigestScheme;
import org.apache.http.message.BasicHeader;

import java.net.HttpURLConnection;
import java.util.HashMap;
import java.util.Map;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.base.ReduceApplication;
import reduce.fz.com.reduce.bean.User;
import reduce.fz.com.reduce.service.preference.UserPreference;

/**
 * Created by qingshengzheng on 15/7/12.
 */
public class ReduceRequest extends StringRequest {


    public ReduceRequest(String url, Response.Listener<String> listener, Response.ErrorListener errorListener) {
        super(url, listener, errorListener);

    }

    public ReduceRequest(int method, String url, Response.Listener<String> listener, Response.ErrorListener errorListener) {
        super(method, url, listener, errorListener);

    }

    @Override
    public Map<String, String> getHeaders() throws AuthFailureError {
        Map<String, String> _headers = new HashMap<String, String>();
        User user = UserPreference.getUser();
        if (user != null) {
            _headers.put("uid", user.uid + "");
            _headers.put("mobile", user.mobile);
        }
        return _headers;
    }
}
